package cn.com.b2office.struts2.action;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import cn.com.b2office.domain.ItemComment;
import cn.com.b2office.domain.User;
import cn.com.b2office.service.ItemCommentService;

import com.opensymphony.xwork2.ActionSupport;

public class AddItemCommentAction extends ActionSupport implements SessionAware {

	private static final long serialVersionUID = 7218644329096318999L;

	private ItemCommentService itemCommentService = null;

	private Map session = null;

	private String itemId = null;

	private String title = null;

	private String comments = null;

	public void setSession(Map session) {
		this.session = session;
	}

	public String execute() throws Exception {
		User user = (User) session.get("user");
		if (user == null)
			return "login";
		ItemComment cmm = new ItemComment();
		cmm.setTitle(title);
		cmm.setComments(comments);
		cmm.setItemId(itemId);
		cmm.setMemberId(user.getMemberId());
		itemCommentService.commetItem(cmm);
		return SUCCESS;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	public void setItemId(String itemId) {
		this.itemId = itemId;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getItemId() {
		return itemId;
	}

	public void setItemCommentService(ItemCommentService itemCommentService) {
		this.itemCommentService = itemCommentService;
	}

}
